home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / DebugStream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  3.2 KB  |  94 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DebugStream.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __DEBUGSTREAM__
  15. #define __DEBUGSTREAM__
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20.  
  21. //#ifndef __STREAM__
  22. //#include <Stream.h>
  23. //#endif
  24.  
  25. #ifndef __IOSTREAM__
  26. #include <iostream.h>
  27. #endif
  28.  
  29. #pragma push
  30. #pragma segment DebugStream
  31.  
  32. /***********************************|****************************************/
  33.  
  34. class debugstream : public ostream 
  35. {
  36. public:
  37.             debugstream(streambuf*);
  38.     virtual ~debugstream();
  39.  
  40.             debugstream&            write ( const char*, int );
  41.  
  42.             debugstream&            operator<< (char c) { put(c); osfx(); return *this; };
  43.             debugstream&            operator<< (short c) { return (debugstream&) ostream::operator << ( (int) c ); };
  44.             debugstream&            operator<< (int c) { return (debugstream&) ostream::operator << ( (int) c ); };
  45.             debugstream&            operator<< (long c) { return (debugstream&) ostream::operator << ( (int) c ); };
  46.  
  47.             debugstream&            operator<< (unsigned char c) { put(c); osfx(); return *this; };
  48.             debugstream&            operator<< (unsigned short c) { return (debugstream&) ostream::operator << ( (unsigned int) c ); };
  49.             debugstream&            operator<< (unsigned int c) { return (debugstream&) ostream::operator << ( (unsigned int) c ); };
  50.             debugstream&            operator<< (unsigned long c) { return (debugstream&) ostream::operator << ( (unsigned int) c ); };
  51.  
  52.             debugstream&            operator<< (const char* s) { return (debugstream&) ostream::operator << ( s ); };
  53.             debugstream&            operator<< (const unsigned char* s) { return debugstream::write ( (char*) s + 1, (int) s [ 0 ] ); };
  54.             debugstream&            operator<< (const void* p) { return (debugstream&) ostream::operator << ( (void*) p ); };
  55.  
  56.             debugstream&            operator<< (ostream& (*f)(ostream&)) { return (debugstream&) (*f)(*this); }
  57.  
  58.             void                     SetEncodedOutput (Boolean newValue);
  59.  
  60. private:    Boolean                 fEncodedCharacterOutput;
  61. };
  62.  
  63. /***********************************|****************************************/
  64.  
  65. class TWWStreamBuf : public streambuf 
  66. {
  67. public:        TWWStreamBuf ();
  68.     virtual ~TWWStreamBuf();
  69.  
  70.     virtual int                     overflow(int c = EOF);
  71.     virtual int                     underflow ();
  72.     
  73.     virtual int sync();
  74. };
  75.  
  76. /***********************************|****************************************/
  77.  
  78. ostream& date (ostream&);        // put the date (short format) into the output stream
  79. ostream& time (ostream&);        // put the time into the output stream
  80. ostream& version (ostream&);    // put the program version
  81. ostream& encoded (ostream&);     // makes the next item output in an encoded character format
  82. inline ostream& deco (ostream& s) { s.setf(ios::dec, ios::basefield); return s; }; 
  83. inline ostream& hexo (ostream& s) { s.setf(ios::hex, ios::basefield); return s; }; 
  84. inline ostream& octo (ostream& s) { s.setf(ios::oct, ios::basefield); return s; }; 
  85.  
  86. inline ostream& operator<< (ostream& s, const StringPtr str) { return s.write ( (char *) &str[1], str[0]); };
  87. inline ostream& OutputOSType (ostream& s, OSType type) { return s.write((const char*) &type, sizeof(type)); };
  88.  
  89. /***********************************|****************************************/
  90.  
  91. #pragma pop
  92.  
  93. #endif    // __DEBUGSTREAM__
  94.